a = 10
#
# def fn2():
#     #如果希望在函数内部修改全局变量则需要使用global关键字来声明变量
#     global a
#     a = 20
#     print(a)
# fn2()
# print(a)
#
def function4():
    """
    locals()是用来获取当前作用域的命名空间
    """
    # scope = globals()
    scope = locals()
    scope["a"] = 30

function4()
'''

    globals()可以在任意位置获取全局命名空间
'''
s = globals()
print(s)
print(a)
if __name__ == "__manin__":
    pass


# scope = locals()
# print(type(scope))
# print(scope)